package org.example.struct.array2;

/**
 * @author liyishan
 * @date 2023/8/28 09:21
 * @apiNote
 */

public class Test00011MaxArea {
    public static void main(String[] args) {

    }

    public static int test(int[] height) {
        int n = height.length;
        int max = Integer.MIN_VALUE;
        for(int i = 0; i < n; i++) {
            for(int j = i+1;j<n;j++){
                max = Math.max(max,(j-i) * Math.min(height[i],height[j]));
            }
        }
        return max;
    }

    public static int test1(int[] height) {
       int l =0,r=height.length-1;
       int ans = 0;
       while(l<r){
           int area = (r-l) * Math.min(height[l],height[r]);
           ans = Math.max(ans,area);
           if(height[l]<=height[r]){
               l++;
           }else{
               r--;
           }
       }
       return ans;
    }
}
